/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  AccessIPFilter.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-14 下午9:45:21
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-14          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.log4j.Logger;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 java.lang.Object#toString(), 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  AccessIPFilter
 * @author  lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class AccessIPFilter implements Filter {

	/**
     * LOGGER 日志对象
     */
    private static final Logger LOGGER = Logger.getLogger(SessionProxyFilter.class);
	
	/**
	 * @param filterConfig
	 * @throws ServletException
	 */
	public void init(FilterConfig filterConfig) throws ServletException {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("AccessIPFilter initialization method is not implemented.");
		}
	}
	
	/**
	 * @param request
	 * @param response
	 * @param chain
	 * @throws IOException
	 * @throws ServletException
	 */
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		
		String clientIp = request.getRemoteAddr();// 获取访问端的IP
		if (LOGGER.isDebugEnabled()) {
		    LOGGER.debug("Request Client IP Address Info:[" + clientIp + "]");
		}
		
		
		chain.doFilter(request, response);
	}
	
	/**
	 * 
	 */
	public void destroy() {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("AccessIPFilter destruction method is not implemented.");
		}
	}
}
